Source: https://sources.debian.org/patches/gnome-font-viewer/3.34.0-2/git_cve_fix.patch/

diff --git a/src/font-model.c b/src/font-model.c
index 658cba8..e66c401 100644
--- a/src/font-model.c
+++ b/src/font-model.c
@@ -33,6 +33,7 @@
 
 #include "font-model.h"
 #include "font-utils.h"
+#include "sushi-font-loader.h"
 
 struct _FontViewModel
 {
@@ -137,7 +138,7 @@ font_view_model_has_face (FontViewModel *self,
     g_autofree gchar *match_name = NULL;
 
     n_items = g_list_model_get_n_items (G_LIST_MODEL (self->model));
-    match_name = font_utils_get_font_name (face);
+    match_name = sushi_get_font_name (face, TRUE);
 
     for (idx = 0; idx < n_items; idx++) {
         FontViewModelItem *item = g_list_model_get_item (G_LIST_MODEL (self->model), idx);
diff --git a/src/font-utils.c b/src/font-utils.c
index 5a75fb3..6a41d26 100644
--- a/src/font-utils.c
+++ b/src/font-utils.c
@@ -23,15 +23,6 @@
 #include "sushi-font-loader.h"
 
 gchar *
-font_utils_get_font_name (FT_Face face)
-{
-    if (g_strcmp0 (face->style_name, "Regular") == 0)
-        return g_strdup (face->family_name);
-
-    return g_strconcat (face->family_name, ", ", face->style_name, NULL);
-}
-
-gchar *
 font_utils_get_font_name_for_file (FT_Library library,
                                    GFile *file,
                                    gint face_index)
@@ -49,7 +40,7 @@ font_utils_get_font_name_for_file (FT_Library library,
         return NULL;
     }
 
-    name = font_utils_get_font_name (face);
+    name = sushi_get_font_name (face, TRUE);
     FT_Done_Face (face);
 
     return name;
diff --git a/src/font-utils.h b/src/font-utils.h
index 6f73bb4..1787bbb 100644
--- a/src/font-utils.h
+++ b/src/font-utils.h
@@ -25,7 +25,6 @@
 #include FT_FREETYPE_H
 #include <gio/gio.h>
 
-gchar * font_utils_get_font_name (FT_Face face);
 gchar * font_utils_get_font_name_for_file (FT_Library library,
                                            GFile *file,
                                            gint face_index);
diff --git a/src/sushi-font-loader.c b/src/sushi-font-loader.c
index f7cf1de..df28c1a 100644
--- a/src/sushi-font-loader.c
+++ b/src/sushi-font-loader.c
@@ -67,6 +67,13 @@ font_load_job_free (FontLoadJob *job)
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (FontLoadJob, font_load_job_free)
 
+static void
+face_data_finalizer (void *object)
+{
+  FT_Face face = object;
+  g_clear_object (&face->generic.data);
+}
+
 static FT_Face
 create_face_from_contents (FontLoadJob *job,
                            gchar **contents,
@@ -88,6 +95,9 @@ create_face_from_contents (FontLoadJob *job,
     return NULL;
   }
 
+  retval->generic.data = g_object_ref (job->file);
+  retval->generic.finalizer = face_data_finalizer;
+
   *contents = g_steal_pointer (&job->face_contents);
   return retval;
 }
@@ -172,3 +182,31 @@ sushi_new_ft_face_from_uri_finish (GAsyncResult *result,
 
   return create_face_from_contents (job, contents, error);
 }
+
+/**
+ * sushi_get_font_name: (skip)
+ *
+ */
+gchar *
+sushi_get_font_name (FT_Face face,
+                     gboolean short_form)
+{
+  const char *style_name = face->style_name;
+  const char *family_name = face->family_name;
+
+  if (family_name == NULL) {
+    /* Try to get the basename of the file this was loaded from */
+    GFile *file = face->generic.data;
+    if (G_IS_FILE (file))
+      return g_file_get_basename (file);
+
+    /* Use an empty string as the last fallback */
+    return g_strdup ("");
+  }
+
+  if (style_name == NULL ||
+      (short_form && g_strcmp0 (style_name, "Regular") == 0))
+    return g_strdup (family_name);
+
+  return g_strconcat (family_name, ", ", style_name, NULL);
+}
diff --git a/src/sushi-font-loader.h b/src/sushi-font-loader.h
index 82aab03..b078e4a 100644
--- a/src/sushi-font-loader.h
+++ b/src/sushi-font-loader.h
@@ -46,4 +46,7 @@ FT_Face sushi_new_ft_face_from_uri_finish (GAsyncResult *result,
                                            gchar **contents,
                                            GError **error);
 
+gchar * sushi_get_font_name (FT_Face face,
+                             gboolean short_form);
+
 #endif /* __SUSHI_FONT_LOADER_H__ */
diff --git a/src/sushi-font-widget.c b/src/sushi-font-widget.c
index 144a3d6..ac1fcd4 100644
--- a/src/sushi-font-widget.c
+++ b/src/sushi-font-widget.c
@@ -378,8 +378,7 @@ build_strings_for_face (SushiFontWidget *self)
     self->sample_string = random_string_from_available_chars (self->face, 36);
 
   g_free (self->font_name);
-  self->font_name = g_strconcat (self->face->family_name, " ",
-                                 self->face->style_name, NULL);
+  self->font_name = sushi_get_font_name (self->face, FALSE);
 }
 
 static gint *
